package com.store.app.utils;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;


/**
 * Created by Ben
 * on 2016/8/5 0005.\
 */
public class OpenTaoBaoApp {
    public static boolean open(Context context, String goods_url) {
        boolean isOpen = false;
//        if(IsInstalledUtils.isAppInstalled(context,"com.taobao.taobao")){
        try {
            ClipboardManager myClipboard;
            myClipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
            ClipData myClip;
            myClip = ClipData.newPlainText("text", goods_url);
            myClipboard.setPrimaryClip(myClip);
            Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.taobao.taobao");
            context.startActivity(intent);
            isOpen = true;
        } catch (Exception e) {
            Log.v("zyl", "无法打开淘宝，请检查本地是否正常安装！");
            Toast.makeText(context, "无法打开淘宝，请检查本地是否正常安装！", Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
//        }else{
//            Toast.makeText(context, "无法打开淘宝，请检查本地权限", Toast.LENGTH_LONG).show();
//        }
        return isOpen;
    }
}
